package com.certificationManager.server.domain.model;

import java.util.Date;

import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

/**
 * @author Benjamin Barbier
 *
 */
@PersistenceCapable
public class User {
    
	@PrimaryKey
    private Key key;
	
	@Persistent
    private String email;
    
	@Persistent
    private String lastName;
    
	@Persistent
    private String firstName;
	
	@Persistent
    private String password;
    
	@Persistent
    private Date inscriptionDate;
    
//    @ManyToOne(fetch = FetchType.LAZY) // @ManyToOne: Page 29 -> http://www.cniug.org/uploadfiles/IBM/2009IIUG/B02_Ferreira_Informix_Apps_with_GWT_and_JPA.pdf
	@Persistent
    private Language language;
    
	/**
	 * Constructor
	 * 
	 * @param lastName : nom de l'utilisateur
	 * @param firstName : prenom de l'utilisateur
	 * @param email : email de l'utilisateur
	 * @param password : password de l'utilisateur
	 * @param inscriptionDate : date de l'inscription de l'utilisateur
//	 * @param language : langue utilisee par l'utilisateur
	 */
	public User(String lastName, String firstName, String email,
			String password, Date inscriptionDate
//			, Language language
			) {
		this.key = KeyFactory.createKey(User.class.getSimpleName(), email);
		this.lastName = lastName;
		this.firstName = firstName;
		this.email = email;
		this.password = password;
		this.inscriptionDate = inscriptionDate;
//		this.language = language;
	}
	
	public void setKey(Key key) {
		this.key = key;
	}

	public Key getKey() {
		return key;
	}
	
	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setPrenom(String firstName) {
		this.firstName = firstName;
	}
	
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
	
	public Date getInscriptionDate() {
		return inscriptionDate;
	}

	public void setInscriptionDate(Date inscriptionDate) {
		this.inscriptionDate = inscriptionDate;
	}

	public Language getLanguage() {
		return language;
	}

	public void setLanguage(Language language) {
		this.language = language;
	}

}
